//package com.info.zhiduoduo.admin.controller;
//
//import com.alipay.api.response.AlipayFundTransUniTransferResponse;
//import com.baomidou.mybatisplus.mapper.Condition;
//import com.info.zhiduoduo.admin.model.formbean.account.MakerLabelFormBean;
//import com.info.zhiduoduo.admin.model.formbean.alipay.AlipayAccountFormBean;
//import com.info.zhiduoduo.admin.model.formbean.alipay.AlipayPrincipalAccountRechargeFormBean;
//import com.info.zhiduoduo.admin.model.formbean.entrust.ListMakerAlipayFormBean;
//import com.info.zhiduoduo.admin.model.formbean.entrust.ListPrincipalFlowFormBean;
//import com.info.zhiduoduo.admin.model.formbean.alipay.MakerIsvIdFormBean;
//import com.info.zhiduoduo.admin.model.formbean.alipay.MakerPrincipalIdFormBean;
//import com.info.zhiduoduo.admin.model.formbean.alipay.PrincipalTransferPrincipalPublicAccountFormBean;
//import com.info.zhiduoduo.admin.model.formbean.invoice.EditRemarkFormBean;
//import com.info.zhiduoduo.admin.service.MakerAliPayService;
//import com.info.zhiduoduo.common.annotation.LogEntity;
//import com.info.zhiduoduo.common.annotation.LogParameter;
//import com.info.zhiduoduo.common.annotation.ZddLog;
//import com.info.zhiduoduo.common.constants.SmartResult;
//import com.info.zhiduoduo.common.constants.system.ZddLogType;
//import com.info.zhiduoduo.common.exception.Asserts;
//import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
//import com.info.zhiduoduo.repository.dto.maker.MakerAlipayAvailableDto;
//import com.info.zhiduoduo.repository.dto.maker.MakerAlipayDto;
//import com.info.zhiduoduo.repository.dto.maker.MakerAlipayPrincipalDto;
//import com.info.zhiduoduo.repository.dto.maker.MakerAlipayPrincipalFlowDto;
//import com.info.zhiduoduo.repository.entity.invoice.Invoice;
//import com.info.zhiduoduo.repository.entity.maker.MakerAlipay;
//import com.info.zhiduoduo.repository.entity.maker.MakerAlipayAccountBook;
//import com.info.zhiduoduo.repository.entity.maker.MakerAlipayAgreement;
//
//import com.info.zhiduoduo.repository.entity.maker.MakerAlipayPrincipal;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.math.BigDecimal;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.validation.Valid;
//
//import io.swagger.annotations.ApiModelProperty;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//
//@RestController
//@RequestMapping("/alipay")
//public class AlipayController {
//
//	@Autowired
//	MakerAliPayService makerAliPayService;
//
//	//*************************************  平台 接口 ******************************** //
//
//	@ZddLog(name = "新建 平台委托人",entities = @LogEntity(entity = MakerAlipayPrincipal.class,parameters =
//	@LogParameter(fields = "id",parameters = "formBean.reqdata")))
//	@ApiOperation(value = "新建 平台委托人")
//	@PostMapping("/createZddPrincipalAgreement")
//	public SmartResult createZddPrincipalAgreement(@RequestBody BaseSimpleFormBean<Integer> formBean) {
//		return makerAliPayService.createZddPrincipalAgreement(formBean);
//	}
//
//	@ApiOperation(value = "查询 平台委托人")
//	@PostMapping("/queryZddPrincipalAgreement")
//	public SmartResult queryZddPrincipalAgreement(@RequestBody BaseSimpleFormBean<Integer> formBean) {
//		return makerAliPayService.queryZddPrincipalAgreement(formBean);
//	}
//
//	@ZddLog(name = "新建 平台委托人的资金记账本",entities = @LogEntity(entity = MakerAlipayPrincipal.class,parameters =
//	@LogParameter(fields = "principalId",parameters = "formBean.reqdata")))
//	@ApiOperation(value = "新建 平台委托人的资金记账本")
//	@PostMapping("/createZddPrincipalAccount")
//	public SmartResult createZddPrincipalAccount(@RequestBody BaseSimpleFormBean<Integer> formBean) {
//		return makerAliPayService.createZddPrincipalAccount(formBean);
//	}
//
//	@ApiOperation(value = "查询 平台委托人的资金记账本")
//	@PostMapping("/queryZddPrincipalAccount")
//	public SmartResult queryZddPrincipalAccount(@RequestBody BaseSimpleFormBean<Integer> formBean) {
//		return makerAliPayService.queryZddPrincipalAccount(formBean);
//	}
//
//	@ZddLog(type = ZddLogType.QUERY, name = "给 平台委托人主账户的记账本充值",entities = @LogEntity(entity = MakerAlipayPrincipal.class,parameters =
//	@LogParameter(fields = "principalId",parameters = "formBean.reqdata.principalId")))
//	@ApiOperation("给 平台委托人主账户的记账本充值")
//	@PostMapping("/fundTransPagePay")
//	public SmartResult fundTransPagePay(@Valid @RequestBody BaseSimpleFormBean<AlipayPrincipalAccountRechargeFormBean> formBean) {
//		return makerAliPayService.principalRecharge(formBean);
//	}
//
//	@ApiOperation("从 平台委托人的主账户记账本转账到创客的记账本")
//	@GetMapping("/transfer2Entrustee")
//	public SmartResult transfer2Entrustee(int principalId, int targetUserId, @ApiParam("单位元,2位小数") BigDecimal amount) {
//		return SmartResult.success(makerAliPayService.transfer2Entrustee(principalId, targetUserId, amount));
//	}
//
//	@ApiOperation("从创客的记账本退款到 平台委托人的主账户记账本, 回退资金")
//	@GetMapping("/entrusteeRefund")
//	public SmartResult entrusteeRefund(int principalId, int fromUserid, @ApiParam("单位元,2位小数") BigDecimal amount) {
//		return SmartResult.success(makerAliPayService.entrusteeRefund(principalId, fromUserid, amount));
//	}
//
//	@ApiOperation("获取 平台委托人主账户流水")
//	@PostMapping("/listPrincipalFlow")
//	public SmartResult<MakerAlipayPrincipalFlowDto> listPrincipalFlow(@RequestBody BaseSimpleFormBean<ListPrincipalFlowFormBean> formBean) {
//		return makerAliPayService.listPrincipalFlow(formBean);
//	}
//
//	@ZddLog(type = ZddLogType.UPDATE, name = "测试受托人创客代付流程", entities = @LogEntity(entity = MakerAlipayAgreement.class, parameters =
//	@LogParameter(fields = "userid", parameters = "formBean.reqdata.userid")))
//	@ApiOperation("测试受托人创客代付流程")
//	@PostMapping("/testEntrusteePay")
//	public SmartResult testEntrusteePay(@RequestBody BaseSimpleFormBean<MakerPrincipalIdFormBean> formBean) {
//		makerAliPayService.testEntrusteePay(formBean);
//		return SmartResult.success();
//	}
//
//	@ApiOperation("获取所有 委托主体列表")
//	@PostMapping("/listZddPrincipals")
//	public SmartResult<MakerAlipayPrincipalDto> listZddPrincipals(@RequestBody BaseSimpleFormBean formBean) {
//		return makerAliPayService.listZddPrincipals(formBean);
//	}
//
//	@ZddLog(name = "委托主体转账给指定主体的公户")
//	@ApiOperation("委托主体转账给指定主体的公户")
//	@PostMapping("/principalTransferPrincipalPublicBankAccount")
//	public SmartResult<AlipayFundTransUniTransferResponse> principalTransferPrincipalPublicBankAccount(@RequestBody BaseSimpleFormBean<PrincipalTransferPrincipalPublicAccountFormBean> formBean) {
//		return makerAliPayService.principalTransferPrincipalPublicBankAccount(formBean);
//	}
//
///*
//	@ApiOperation("委托主体代付给企业公户")
//	@PostMapping("/principalPay2PublicBankAccount")
//	public SmartResult<AlipayFundTransUniTransferResponse> principalPay2PublicBankAccount(@RequestBody BaseSimpleFormBean<PrincipalPayPublicAccountFormBean> formBean) {
//		return makerAliPayService.principalPay2PublicBankAccount(formBean);
//	}*/
//
//	//************************************* 创客 接口 ******************************** //
//
//	@ZddLog( type = ZddLogType.UPDATE,name = "创客绑定企业支付宝账号(或更新)" , entities = @LogEntity(entity = MakerAlipay.class,parameters =
//	@LogParameter(fields = "userid",parameters = "formBean.reqdata.userid")))
//	@ApiOperation("创客绑定企业支付宝账号(或更新)")
//	@PostMapping("/bindAlipy")
//	public SmartResult bindAlipay(@Valid @RequestBody BaseSimpleFormBean<AlipayAccountFormBean> formBean) {
//		return makerAliPayService.bindAlipay(formBean);
//	}
//	@ApiOperation("删除企业支付宝账号")
//	@PostMapping("/deleteBindAlipay")
//	public SmartResult deleteBindAlipay(@RequestBody BaseSimpleFormBean<Integer> formBean) {
//		return makerAliPayService.deleteBindAlipay(formBean);
//	}
//	@ZddLog(type = ZddLogType.UPDATE, name = "保存创客（创客支付表）标签", entities = {
//			@LogEntity(entity = MakerAlipay.class, parameters = @LogParameter(fields = "userid", parameters = "formBean.reqdata" +
//					".userid[i]"))})
//	@ApiOperation("保存创客（创客支付表）标签")
//	@PostMapping("/saveMakerAlipayLabel")
//	public SmartResult<MakerAlipayDto> saveMakerAlipayLabel(@RequestBody @Valid BaseSimpleFormBean<MakerLabelFormBean> formBean) {
//		return makerAliPayService.saveMakerAlipayLabel(formBean);
//	}
//
//	@ApiOperation("获取已绑定支付宝账号的创客列表")
//	@PostMapping("/listMakerAlipay")
//	public SmartResult<MakerAlipayDto> listMakerAlipay(@Valid @RequestBody BaseSimpleFormBean<ListMakerAlipayFormBean> formBean) {
//		return makerAliPayService.listMakerAlipay(formBean);
//	}
//
//	@ApiOperation("获取已绑定支付宝账号的创客列表(只返回已通过测试, 且协议正常的创客, 按支付宝账本余额排序)")
//	@PostMapping("/listAvailableMakerAlipay")
//	public SmartResult<MakerAlipayAvailableDto> listAvailableMakerAlipay(
//			@Valid @RequestBody BaseSimpleFormBean<ListMakerAlipayFormBean> formBean) {
//		return makerAliPayService.listAvailableMakerAlipay(formBean);
//	}
//
//	@ZddLog(type = ZddLogType.UPDATE, name = "测试受托人创客代付流程", entities = @LogEntity(entity = MakerAlipayAgreement.class, parameters =
//	@LogParameter(fields = "userid", parameters = "formBean.reqdata.userid")))
//	@ApiOperation(value = "创客签约支付宝安全发协议")
//	@PostMapping("/userAgreementPageSign")
//	public SmartResult alipayUserAgreementPageSign(@Valid @RequestBody BaseSimpleFormBean<MakerIsvIdFormBean> formBean) {
//		return makerAliPayService.userAgreementPageSign(formBean);
//	}
//
//	@ZddLog(type = ZddLogType.UPDATE, name = "测试受托人创客代付流程", entities = @LogEntity(entity = MakerAlipayAgreement.class, parameters =
//	@LogParameter(fields = "userid", parameters = "formBean.reqdata.userid")))
//	@ApiOperation(value = "创客解约支付宝安全发协议")
//	@PostMapping("/userAgreementUnsign")
//	public SmartResult alipayUserAgreementUnsign(@Valid @RequestBody BaseSimpleFormBean<MakerIsvIdFormBean> formBean) {
//		return makerAliPayService.userAgreementUnsign(formBean);
//	}
//
//	@ApiOperation(value = "查询创客支付宝安全发协议")
//	@PostMapping("/userAgreementQuery")
//	public SmartResult alipayUserAgreementQuery(@Valid @RequestBody BaseSimpleFormBean<MakerIsvIdFormBean> formBean) {
//		return makerAliPayService.userAgreementQuery(formBean);
//	}
//
//	@ZddLog(name = "创建创客的资金记账本",entities = @LogEntity(entity = MakerAlipayAccountBook.class,parameters =
//	@LogParameter(fields = "userid",parameters = "formBean.reqdata.userid")))
//	@ApiOperation("创建创客的资金记账本")
//	@PostMapping("/fundAccountBookCreate")
//	public SmartResult fundAccountBookCreate(@Valid @RequestBody BaseSimpleFormBean<MakerIsvIdFormBean> formBean) {
//		return makerAliPayService.fundAccountBookCreate(formBean);
//	}
//
//	@ZddLog(type = ZddLogType.QUERY, name = "查询创客的记账本余额等信息",entities = @LogEntity(entity = MakerAlipayAccountBook.class,parameters =
//	@LogParameter(fields = "userid",parameters = "formBean.reqdata.userid")))
//	@ApiOperation("查询创客的记账本余额等信息")
//	@PostMapping("/fundAccountBookQuery")
//	public SmartResult fundAccountBookQuery(@Valid @RequestBody BaseSimpleFormBean<MakerIsvIdFormBean> formBean) {
//		return makerAliPayService.fundAccountBookQuery(formBean);
//	}
//
//	@GetMapping("/appPay")
//	public String appPay(HttpServletRequest request) {
//		return makerAliPayService.appPayNotify(request);
//	}
//
//	@ApiOperation(value = "重新支付-受托人创客重新支付给自然人", notes = "只能对支付失败的子项目重新支付")
//	@GetMapping("/entrusteeRepay")
//	public SmartResult entrusteeRepay(int projectId) {
//		makerAliPayService.entrusteeRepay(projectId);
//		return SmartResult.success();
//	}
//
//	@GetMapping("/fundTransOrderQuery")
//	public SmartResult fundTransOrderQuery(int bizType, String orderNo) {
//		return makerAliPayService.fundTransOrderQuery(bizType, orderNo);
//	}
//
//	// ****************************** 回调处理 ***************************************//
//
//	@RequestMapping("/notify/userAgreementPageSign")
//	public String userAgreementPageSignNotify(HttpServletRequest request) {
//		return makerAliPayService.userAgreementSignNotify(request);
//	}
//
//	@ApiModelProperty("支付宝异步回调通知接口, 1.商户给自身记账本充值 2:记账本之间调拨转账 3:代发到支付宝账户或银行卡")
//	@RequestMapping("/notify/transOrderChanged")
//	public String transOrderChangedNotify(HttpServletRequest request) {
//		return makerAliPayService.transOrderChangedNotify(request);
//	}
//
//	@ApiOperation("添加支付宝备注")
//	@PostMapping("/addAlipayRemarks")
//	public SmartResult addAlipayRemarks(@RequestBody BaseSimpleFormBean<EditRemarkFormBean> formBean) {
//		MakerAlipay makerAlipay = new MakerAlipay()
//				.selectOne(Condition.create()
//						.eq("userid", formBean.getReqdata().getId())
//						.eq("deleted",0));
//		if (null == makerAlipay) return SmartResult.fail("数据不存在");
//		if (!makerAlipay.setRemarks(formBean.getReqdata().getRemark()).updateById()) return SmartResult.fail("修改失败,稍后重试");
//		return SmartResult.success();
//	}
//
//}
